#ifndef NETREQUESTDEVICE_HH_
#define NETREQUESTDEVICE_HH_

#include <assert.h>
#include <pthread.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#include <netinet/in.h>

#include <errno.h>

#include <iostream>

#include <lagniappe/RequestDevice.h>
#include <lagniappe/RCon.h>
#include <lagniappe/RData.h>

#include <sysmodel/Synchronized.hh>

#include "NetRequest.hh"

extern int errno;

const uint32_t BUFSIZE = 8192;
const uint32_t LAGNIAPPE_PORT = 7775;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

void * startDevice(void * arg);

#ifdef __cplusplus
}
#endif /* __cplusplus */

class NetRequestDevice : public lagniappe::RequestDevice, Synchronized
{
  pthread_t coreThread;
  socket_t listener;
  static int procNum;
  bool fromSet;
  std::string intfName;
  bool sysReady;
  fd_set openSet;
  socket_t maxFD;
public:
  NetRequestDevice(std::string intf);
  ~NetRequestDevice();
  void process();
  virtual void run(lagniappe::RCon * rcon);
  virtual void start();
};


#endif // NETREQUESTDEVICE_HH_
